﻿using Blog190311.Areas.Back.Models.DAL;
using Blog190311.Models.DBModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Blog190311.Areas.Back.Controllers
{
    [Authorize]
    public class RecommendController : Controller
    {
        // GET: Back/Recommend
        public ActionResult Index()
        {
            return View();
        }

        RecommendService ser = new RecommendService();

        public ActionResult GetTuijianPage(int limit, int page, string weizhi, string quanzhong)
        {
            List<RecArticle> list = ser.GetTuijian(limit, page, weizhi, quanzhong);
            int num = ser.GetCount(weizhi, quanzhong);
            return Json(new { code = 0, msg = "", count = num, data = list }, JsonRequestBehavior.AllowGet);
        }

        public ActionResult Add()
        {
            return View();
        }

        public ActionResult SaveTui(RecArticle recarticle)
        {
            int num = ser.SaveTui(recarticle);
            return Content(num.ToString());
        }

        public ActionResult UpdateTui(RecArticle recarticle)
        {
            int num = ser.UpdateTui(recarticle);
            return Content(num.ToString());
        }

        public ActionResult EditTui(int id)
        {
            RecArticle recarticle = ser.GetTuiById(id);
            return View(recarticle);
        }

        public ActionResult DelTui(int id)
        {
            int num = ser.DelTui(id);
            return Content(num.ToString());
        }
    }
}